package initdb

import (
	baseLog "gitee.com/zaiqiang231/go-base-app/base_app/log"
	baseStore "gitee.com/zaiqiang231/go-base-app/base_app/store"
	baseInitdb "gitee.com/zaiqiang231/go-base-app/base_app/store/initdb"
	"gitee.com/zaiqiang231/zcamp-service-camp/app/model"
)

type initCondition struct {
	baseInitdb.DbTable[model.Condition]
}

func (i initCondition) GetTable() baseStore.TableInterface {
	return model.Condition{}
}

func (i initCondition) InitData(ds *baseStore.Datastore) {
	var level1 []model.Condition
	level1 = append(level1,
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    0,
			Name:        "类型",
			Level:       1,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    0,
			Name:        "环境",
			Level:       1,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    0,
			Name:        "配套",
			Level:       1,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    0,
			Name:        "出行",
			Level:       1,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
	)
	err := ds.DB.Create(&level1).Error
	if err != nil {
		baseLog.Errorf("initCondition level 1 insert fail, %v", err)
		return
	}
	var level2 []model.Condition
	level2 = append(level2,
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[0].ID),
			Name:        "营地类型",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionSingleSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[1].ID),
			Name:        "营地环境",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[1].ID),
			Name:        "场地类型",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[2].ID),
			Name:        "营地要求",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[2].ID),
			Name:        "基础设施",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[2].ID),
			Name:        "营地活动",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
		model.Condition{
			Status:      model.DataStatusOnline,
			ParentId:    int64(level1[3].ID),
			Name:        "推荐车型",
			Level:       2,
			Sort:        1,
			MultiSelect: model.ConditionMultiSelect,
		},
	)
	err = ds.DB.Create(&level2).Error
	if err != nil {
		baseLog.Errorf("initCondition level 2 insert fail, %v", err)
		return
	}

	var level3 []model.Condition
	level3 = append(level3,
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[0].ID),
			Name:     "收费营地",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[0].ID),
			Name:     "免费营地",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[1].ID),
			Name:     "海岸",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[1].ID),
			Name:     "森林",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[2].ID),
			Name:     "木平台",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[2].ID),
			Name:     "草坪",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[3].ID),
			Name:     "拎包入住",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[3].ID),
			Name:     "可自带帐篷",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[4].ID),
			Name:     "烧烤场",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[4].ID),
			Name:     "淋浴间",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[5].ID),
			Name:     "露天电影",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[5].ID),
			Name:     "观日",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[6].ID),
			Name:     "两驱",
			Level:    3,
			Sort:     1,
		},
		model.Condition{
			Status:   model.DataStatusOnline,
			ParentId: int64(level2[6].ID),
			Name:     "四驱",
			Level:    3,
			Sort:     1,
		},
	)
	err = ds.DB.Create(&level3).Error
	if err != nil {
		baseLog.Errorf("initCondition level 3 insert fail, %v", err)
		return
	}
}
